<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<fmt:bundle
	basename="br.com.universidade.castelo.branco.resources.ApplicationResources"
	prefix="">

	<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script type="text/javascript">

function chamaEnviarPesquisa(){
$(function() {
    $( "#dialog-confirmaEnvio" ).dialog({
      resizable: false,
      height:140,
      modal: true,
      buttons: {
        "OK": function() {
        	$( this ).dialog( "close" );
        	$( "#enviar" ).submit();
        	
        },
        "Cancelar": function() {
          $( this ).dialog( "close" );
        }
      }
    });
  });
} 

</script>
	</head>

	<body>
		<jsp:include page="/WEB-INF/views/pesquisadesatisfacao/menu.jsp"
			flush="true"></jsp:include>

		<img src="resources/imagens/pixel_transparente.gif" height="5%"
			width="10%">
			
			<div align="center">

		<fieldset id="fieldsetConsulta">

			<legend id="alinhamentoFormConsulta">
				<h3>
					<fmt:message key="pds.nome.aplicacao"></fmt:message>
				</h3>
			</legend>

			<table class=linhasAlternadas align="center">

				<tr>
					<th><fmt:message key="consulta.modulo.pesquisa.campo.tema"></fmt:message></th>
					<th><fmt:message key="consulta.modulo.pesquisa.campo.objetivo"></fmt:message></th>
					<th><fmt:message key="consulta.modulo.pesquisa.campo.comentario"></fmt:message></th>
					<th><fmt:message key="consulta.modulo.pesquisa.campo.data.inicio"></fmt:message></th>
					<th><fmt:message key="consulta.modulo.pesquisa.campo.data.termino"></fmt:message></th>

				</tr>

				<tr>
					<td>${pesquisa.tema}</td>
					<td>${pesquisa.objetivo}</td>
					<td>${pesquisa.comentario}</td>
					<td><fmt:formatDate value="${pesquisa.dataInicio}"/></td>
					<td><fmt:formatDate value="${pesquisa.dataTermino}"/></td>
				</tr>

			</table>
			
		</fieldset>
		
		<img src="resources/imagens/pixel_transparente.gif" height="5%" width="15%">
		
		<fieldset id="fieldsetFormularioQuestionario">
		
			<form id="enviar" class=linhasAlternadas action="respostaPesquisa" method="post">
			
			<table id="tituloQuestionario" align="center">
				
				
				<tr>
					<td>&nbsp;&nbsp;<h1> <fmt:message key="pesquisas.modulo.responder.campo.questionario"></fmt:message>	${questionario.titulo} </h1>
					
					<input type="hidden" name="id_questionario" value="${questionario.id_questionario}" />	
					
					<input type="hidden" name="id_pesquisa" value="${pesquisa.id_pesquisa}" />		
					
					</td>
				</tr>
				
				<tr>
					<td>
						<br />
						<br />
						<br />
						<br />
						<br />
					</td>
				</tr>
			</table>

			<table id="tableMargem" align="left">
					<div>
					<% Integer cont = 0; 
							   String questao="questao";
							%>

						<c:forEach items="${relacionamentos}" var="relacionamento">
							<tr>
								<td id="textoPergunta">
								
								${relacionamento.ordemPergunta} - ${relacionamento.pergunta.descricao}
								
								<input type="hidden" name="id_pergunta" value="${relacionamento.id_pergunta}" />
								
								<input type="hidden" name="id_modelo_resposta" value="${relacionamento.modeloResposta.id_modelo_resposta}" />
								
								<input type="hidden" name="ordemPergunta" value="${relacionamento.ordemPergunta}" />
								
								</td>
								
								
							</tr>
							
							<%cont ++; %>

							<c:forEach items="${relacionamento.modeloResposta.alternativas}" var="modeloAlternativa">
								<tr>
									<td id="tamanhoRadio">
										
										<input type="hidden" name="id_modelo_alternativa" value="${modeloAlternativa.id_modelo_alternativa}" />
										
										<input type="hidden" name="alt_resposta" value="${modeloAlternativa.alt_resposta}" />
										
										<input id="inputRadio" type="radio" name="<%=questao+cont.toString()%>" value="${modeloAlternativa.id_modelo_alternativa}">	
										
										${modeloAlternativa.alt_resposta}</td>
								</tr>
								
								
							</c:forEach>


							<tr>
								<td><br /></td>

							</tr>

						</c:forEach>
					</div>

					<tr>
						<td><input id="botao"  type="button" onclick="chamaEnviarPesquisa()" value='<fmt:message key="pds.botao.responder"></fmt:message>'>
						</td>

						<td><input id="botao" type="reset"
							value='<fmt:message key="pds.botao.limpar"></fmt:message>'>
						</td>
					</tr>
					
					<tr>
						<td><br /></td>
					</tr>
				</table>
			</form>
		  </fieldset>
		  <table>
				<tr> 
					<td>  <div id="dialog-confirmaEnvio" title="Enviar" style="display: none;">
						<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 1px 0;"></span><fmt:message key="pds.responder.pesquisa"></fmt:message></p>
					</div>
					</td> 
				</tr> 
		</table>
		</div>
	</body>
</fmt:bundle>
</html>